package com.changgou.oauth.intercepter;

import com.changgou.oauth.util.AdminToken;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TokenReuestInter implements RequestInterceptor {
    /**
     * feign执行之前进行拦截
     * @param requestTemplate
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        // 生成管理员令牌
        String token = AdminToken.adminToken();
        //把令牌放入到头信息中
        requestTemplate.header("Authorization", "bearer "+token);
    }
}
